#include "distancefilter.h"

DistanceFilter::DistanceFilter(void)
{
	mode = Between;
	distAbove = 0;
	distBelow = 1000;
}

DistanceFilter::~DistanceFilter(void)
{
}

bool DistanceFilter::accepts(AnatomicalLink* link)
{
	switch(mode)
	{
		case Above:
			return (link->distance() >= distAbove);
		case Below:
			return (link->distance() <= distBelow);
		case Between:
			return ((link->distance() >= distAbove) &&
				(link->distance() <= distBelow));
		default:
			return true;
	}
}

void DistanceFilter::setFilterToAcceptAbove(double dist)
{
	mode = Above;
	distAbove = dist;
	emit filterChanged(this);
}

void DistanceFilter::setFilterToAcceptBelow(double dist)
{
	mode = Below;
	distBelow = dist;
	emit filterChanged(this);
}

void DistanceFilter::setFilterToAcceptBetween(double dist1, double dist2)
{
	mode = Between;
	distAbove = dist1;
	distBelow = dist2;
	emit filterChanged(this);
}
